package com.bt.lms.ui.page.course;

import com.bt.lms.ui.action.course.ExamineCourseReturnBtnAction;
import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;

/**
 * 课程管理
 * 查看课程信息
 */
public class DetailCourse extends VBox {


    /**
     * 标签的宽
     */
    private Integer labelWidth = 200;

    /**
     * 宽
     */
    public Integer preWidth = 1280;


    public DetailCourse(){

        //初始化所在位置
        initLocation();
        //查看课程标题
        initExamineCourseLabel();
        //初始化编辑内容
        initBasicInfo();
        //初始化保存按钮
        initSaveButton();
        Insets insets = new Insets(10);
        this.setPadding(insets);
        this.setSpacing(25);
        this.setPrefWidth(preWidth);
    }

    /**
     * 初始化所在位置
     */
    public void initLocation(){

        HBox hBox = new HBox();
        Insets insets = new Insets(10);
        hBox.setPadding(insets);
        Label label = new Label("当前位置：🏠>教学管理>课程管理>查看课程");
        Font font = Font.font("仿宋", FontWeight.THIN, FontPosture.REGULAR,18);
        label.setFont(font);
        hBox.getChildren().add(label);
        this.getChildren().add(hBox);

    }


    /**
     * 查看课程标题
     */
    public void initExamineCourseLabel(){

        Label label = new Label("查看课程");
        Font font = Font.font("仿宋", FontWeight.BLACK, FontPosture.REGULAR,25);
        Color rgb = Color.rgb(247, 69, 69);
        label.setTextFill(rgb);
        label.setFont(font);
        this.getChildren().add(label);

    }


    /**
     * 初始化编辑内容
     */
    public void initBasicInfo(){

        //基本信息主盒子
        VBox vBox = new VBox();
        Insets insets = new Insets(10);
        vBox.setPadding(insets);
        vBox.setSpacing(40);
        //课程编号
        HBox courseNumberHBox = new HBox();
        courseNumberHBox.setSpacing(10);
        Label courseNumberLabel = new Label("课程编号");
        courseNumberLabel.setPrefWidth(labelWidth);
        Label courseNumberDetailLabel = new Label("2222");
        courseNumberHBox.getChildren().addAll(courseNumberLabel,courseNumberDetailLabel);
        //课程名称
        HBox courseNameHBox = new HBox();
        courseNameHBox.setSpacing(10);
        Label courseNameLabel = new Label("课程名称");
        courseNameLabel.setPrefWidth(labelWidth);
        Label courseNameDetailLabel = new Label("java高级工程师");
        courseNameHBox.getChildren().addAll(courseNameLabel,courseNameDetailLabel);
        //课程英文名称
        HBox courseEnglishNameHBox = new HBox();
        courseEnglishNameHBox.setSpacing(10);
        Label courseEnglishNameLabel = new Label("课程英文名称");
        courseEnglishNameLabel.setPrefWidth(labelWidth);
        Label courseEnglishNameDetailLabel = new Label("java");
        courseEnglishNameHBox.getChildren().addAll(courseEnglishNameLabel,courseEnglishNameDetailLabel);
        //课程开设单位
        HBox courseOpenUnitHBox = new HBox();
        courseOpenUnitHBox.setSpacing(10);
        Label courseOpenUnitLabel = new Label("所属的学习中心");
        courseOpenUnitLabel.setPrefWidth(labelWidth);
        Label courseOpenUnitDetailLabel = new Label("北京师范大学");
        courseOpenUnitHBox.getChildren().addAll(courseOpenUnitLabel,courseOpenUnitDetailLabel);

        //适合层次
        HBox applyLevelHBox = new HBox();
        applyLevelHBox.setSpacing(10);
        Label applyLevelLabel = new Label("适合层次");
        applyLevelLabel.setPrefWidth(labelWidth);
        Label applyLevelDetailLabel = new Label("高中");
        applyLevelHBox.getChildren().addAll(applyLevelLabel,applyLevelDetailLabel);

        //版本
        HBox versionsHBox = new HBox();
        versionsHBox.setSpacing(10);
        Label versionsLabel = new Label("版本");
        versionsLabel.setPrefWidth(labelWidth);
        Label versionsDetailLabel = new Label("2622");
        versionsHBox.getChildren().addAll(versionsLabel,versionsDetailLabel);


        //小盒子放大盒子里
        ObservableList<Node> children = vBox.getChildren();
        children.addAll(courseNumberHBox,courseNameHBox,courseEnglishNameHBox,courseOpenUnitHBox,applyLevelHBox,versionsHBox);

        //大盒子放到主盒子
        this.getChildren().add(vBox);

    }

    /**
     * 初始化返回按钮
     */
    public void initSaveButton(){

        //按钮小盒子
        HBox hBox = new HBox();
        hBox.setSpacing(10);
        hBox.setAlignment(Pos.CENTER);

        Button returnBtn = new Button("返回");
        returnBtn.setCursor(Cursor.HAND); //鼠标移入添加小手图案
        BtnStyle.cancelBtn(returnBtn);
        ExamineCourseReturnBtnAction examineCourseReturnBtnAction = new ExamineCourseReturnBtnAction(this);
        returnBtn.setOnAction(examineCourseReturnBtnAction);

        //放入按钮盒子
        hBox.getChildren().add(returnBtn);

        //放入大盒子
        this.getChildren().add(hBox);

    }



}
